
% Objective-C Foundation Reference Card (part 2)
% Copyright (c) 2003 Dick van Oudheusden
% TeX Format

% Note: Comment the following line and Uncomment the three next for PDF
% generation (command is pdftex vimqrc.tex).

% Uncomment the following line for dvi/ps generation: tex forth-refcard.tex; dvips -o forth-refcard.ps forth-refcard.dvi
%\input outopt.tex

% Uncomment the following three lines for PDF generation: pdftex forth-refcard.tex
\pdfoutput=1
\pdfpageheight=21cm
\pdfpagewidth=29.7cm

% Font definitions
\font\bigbf=cmb12
\font\smallbf=cmb10
\font\smallrm=cmr8
\font\smalltt=cmtt8
\font\smallit=cmmi8
\font\tinyit=cmmi5

\def\cm#1#2{{\smalltt#1}\dotfill{\smallrm#2}\par}
\def\cn#1{\hfill$\lfloor$ {\smallrm#1}\par}
\def\sect#1{\vskip 0.7cm \hfil{\smallbf#1}\hfil\par}
\def\para#1{{\smallit#1}\par}
\def\vsep{\vskip 6pt}

% Characters definitions
\def\bs{$\backslash$}
\def\backspace{$\leftarrow$}
\def\ctrl{{\rm\char94}\kern-1pt}
\def\enter{$\hookleftarrow$}
\def\or{\thinspace{\tinyit{or}}\thinspace}
\def\key#1{$\langle${\rm{\it#1}}$\rangle$}
\def\rapos{\char125}
\def\lapos{\char123}
\def\bs{\char92}
\def\tild{\char126}

% Three columns definitions
\parindent 0pt
%\nopagenumbers
\hoffset=-1.56cm
\voffset=-1.54cm
\newdimen\fullhsize
\fullhsize=27.9cm
\hsize=8.5cm
\vsize=19cm
\def\fullline{\hbox to\fullhsize}
\let\lr=L
\newbox\leftcolumn
\newbox\midcolumn
\output={
  \if L\lr
    \global\setbox\leftcolumn=\columnbox
    \global\let\lr=M
  \else\if M\lr
    \global\setbox\midcolumn=\columnbox
    \global\let\lr=R
  \else
    \tripleformat
    \global\let\lr=L
  \fi\fi
  \ifnum\outputpenalty>-20000
  \else
    \dosupereject
  \fi}
\def\tripleformat{
  \shipout\vbox{\fullline{\box\leftcolumn\hfil\box\midcolumn\hfil\columnbox}}
  \advancepageno}
\def\columnbox{\leftline{\pagebody}}

% Card content
% Header
%\hrule\vskip 3pt
\hfil{\bf OBJECTIVE-C FOUNDATION CLASSES}\hfil\par
\hfil{\bf REFERENCE CARD}\hfil\par
\hfil{\bf Part 2: Collections}\hfil\par
\vskip 2pt\hrule

\sect{DArray}
\para{Methods}
\cm{- init}{Init empty array}
\cm{- init :(long) length}{Init array with length}
\cm{- free}{Free the array, not the objects}
\cm{- deepFree}{Free the array and the objects}
\cm{- (long) length}{Get length of array}
\cm{- length :(long) length}{Increase length of array}
\cm{- (BOOL) isValid :(long) index}{Test if index is valid}
\cm{- (id) set :(long) index :(id) obj}{Set object in array}
\cm{- (id) get :(long) index}{Get object in array}
\cm{- (long) index :(id) obj}{Smallest index for object}
\cm{- (long) rindex :(id) obj}{Greatest index for object}
\cm{- (long) count :(id) obj}{Count occurences for object}
\cm{- (BOOL) has :(id) obj}{Test presence object}
\cm{- each :(SEL) sel}{Perform sel for every object}

\sect{DList}
\para{Methods}
\cm{- init}{Init an empty list}
\cm{- free}{Free the list, not the objects}
\cm{- (BOOL) isEmpty}{Test for empty list}
\cm{- (long) length}{Get number elements in list}
\cm{- (DList *) prepend :(id) obj}{Prepend object in list}
\cm{- (DList *) append :(id) obj}{Append object in list}
\cm{- (id) pop}{Pop the last object in the list}
\cm{- (DList *) insert :(long) index :(id) obj}{}
\cn{Insert object indexed in list}
\cm{- (id) set :(long) index :(id) obj}{Set the object in list}
\cm{- (id) get :(long) index}{Get the object in list}
\cm{- (DList *) get :(long) from :(long) to}{}
\cn{Get new list with ranged objects (references)}
\cm{- (id) delete :(long) index}{Delete indexed object from list}
\cm{- (DList *) delete :(long) from :(long) to}{}
\cn{Remove ranged objects to new list}
\cm{- (long) count :(id) obj}{Count the object in list}
\cm{- (long) index :(id) obj}{Smallest index for object}
\cm{- (long) rindex :(id) obj}{Biggest index for object}
\cm{- (BOOL) has :(id) obj}{Test if object in list}
\cm{- (BOOL) remove :(id) obj}{Remove object from list}
\cm{- (DList *) reverse}{Reverse sequence of objects in list}
\cm{- (DList *) each :(SEL) sel}{Perform method for every object}
\cm{+ (DList *) split :(char *) str :(char) sep :(int) max}{}
\cn{Split string in list of strings}
\cm{- (DText *) join :(char) sep}{Join list of strings to string}

\sect{DListIterator}
\para{Methods}
\cm{- (DListIterator *) init}{Init iterator without list}
\cm{- (DListIterator *) init :(DList *) list}{Init iterator with list}
\cm{- (DListIterator *) list :(DList *) list}{Set new list for iterator}
\cm{- (id) first}{Go to first object in list}
\cm{- (id) last}{MGo to last object in list}
\cm{- (id) next}{Go to next object in list}
\cm{- (id) prev}{Go to previous object in list}
\cm{- (id) set :(id) obj}{Set object in list}
\cm{- (id) get}{Get object in list}

\sect{DMap}
\para{Methods}
\cm{- init :(Class) key}{Init tree with key of type class}
\cm{- free}{Free the tree, not the objects}
\cm{- deepFree}{Free the tree and stored objects}
\cm{- (long) length}{Return number of objects in tree}
\cm{- (BOOL) isEmpty}{Test for empty tree}
\cm{- (BOOL) insert :(Object *) key :(Object *) obj}{}
\cn{Insert an object in tree}
\cm{- (id) remove :(Object *) key}{Remove an object}
\cm{- (BOOL) contains :(Object *) key}{Test for presence}
\cm{- (Object *) search :(Object *) key}{Search for key}
\cm{- (DList *) keys}{Return new list with all keys}
\cm{- (DList *) rkeys}{Return new list with all keys (reversed)}
\cm{- (DList *) objects}{Return new list with all objects}

\sect{DMapIterator}
\para{Implements: DIterator}
\para{Methods}
\cm{- init}{Init iterator without tree}
\cm{- init (DAvlTree *) tree}{Init iterator with tree}
\cm{- tree (DAvlTree *) tree}{Set new tree for iterator}
\cm{- (Object *) first}{Go to first object in tree}
\cm{- (Object *) last}{Go to last object in tree}
\cm{- (Object *) next}{Go to next object in tree}
\cm{- (Object *) prev}{Go to previous object in tree}
\cm{- (BOOL) object :(Object *) obj}{Set object in tree}
\cm{- (Object *) object}{Get object in tree}
\cm{- (Object *) key}{Get key in tree}

\sect{DHashTable}
\para{Methods}
\cm{- init :(Class) key}{Init table with key class}
\cm{- init :(Class) key :(ulong) size :(double) load}{}
\cn{Init table with key class, start size and load factor}
\cm{- free}{Free the table, not the objects}
\cm{- deepFree}{Free the table and the objects}
\cm{- (long) length}{Return number of objects in table}
\cm{- (BOOL) isEmpty}{Test for empty table}
\cm{- (double) load}{Return the load factor}
\cm{- load :(double) load}{Set the load factor (>0.0)}
\cm{- (ulong) size}{Return the size of the table}
\cm{- size :(ulong) size}{Set the size of the table}
\cm{- (BOOL) insert :(id) key :(id) obj}{Insert object in table}
\cm{- (BOOL) delete :(id) key}{Remove object from table}
\cm{- (BOOL) has :(id) key}{Test for presence in table}
\cm{- get :(id) key}{Return object in table}
\cm{- each :(SEL) sel}{Perform method for every object}
\cm{- (DList *) keys}{Return new list with all keys}
\cm{- (DList *) objects}{Return new list with all objects}

\sect{DHashIterator}
\para{Methods}
\cm{- init}{Init empty table iterator}
\cm{- init :(DHashTable *) table}{Init table iterator}
\cm{- hashTable :(DHashTable *) table}{Set table for iterator}
\cm{- first}{Go to first object in table}
\cm{- next}{Go to next object in table}
\cm{- prev}{Go to previous object in table}
\cm{- last}{Go to last object in table}
\cm{- (id) object :(id) obj}{Set object in table}
\cm{- (id) object}{Get object in table}
\cm{- key}{Get key for object in table}

\sect{DTree}
\para{Methods}
\cm{- (DTree *) init}{Init empty tree}
\cm{- free}{Free the tree, not the objects}
\cm{- deepFree}{Free the tree and the objects}
\cm{- (long) length}{Return the number of objects in tree}
\cm{- (BOOL) isEmpty}{Test empty tree}
\cm{- (BOOL) has :(id) obj}{Test if an object is in the tree}
\cm{- (long) count :(id) obj}{Count occurences of object}
\cm{- (DTree *) each :(SEL) sel}{Perform sel for each object}

\sect{DTreeIterator}
\para{Methods}
\cm{- (DTreeIterator *) init :(DTree *) tree}{}
\cn{Init iterator with tree, move to root}
\cm{- (id) first}{Move iterator to first node}
\cm{- (id) next}{Move iterator to next node}
\cm{- (id) prev}{Move iterator to previous node}
\cm{- (id) last}{Move iterator to last node}
\cm{- (BOOL) isFirst}{Test for first node}
\cm{- (BOOL) isLast}{Test for last node}
\cm{- (BOOL) isRoot}{Test for root node}
\cm{- (BOOL) hasChildren}{Test for children for this node}
\cm{- (id) root}{Move to the root node}
\cm{- (id) parent}{Move to the parent node}
\cm{- (id) child}{Move to the (first) child node from parent}
\cm{- (id) set :(id) obj}{Set the object in the current node}
\cm{- (id) get}{Return the object in the current node}
\cm{- (DTreeIterator *) prepend :(id) obj}{}
\cn{Prepend new child for current parent}
\cm{- (DTreeIterator *) append :(id) obj}{}
\cn{Append new child for current parent}
\cm{- (DTreeIterator *) before :(id) obj}{}
\cn{Insert new node before current node}
\cm{- (DTreeIterator *) after :(id) obj}{}
\cn{Insert new node after current node}
\cm{- (id) remove}{Remove current node, no children}

% Footer
\vfill \hrule\smallskip
{\smallrm Version 0.2.0. This card may be freely distributed under 
the terms of the GNU general public licence\par
Copyright \copyright\ {\oldstyle 2003} by Dick van Oudheusden}

% Ending
\supereject
\if L\lr \else\null\vfill\eject\fi
\if L\lr \else\null\vfill\eject\fi
\bye

% EOF
